package com.cy.pj.sys.web.controller;

import com.cy.pj.sys.common.util.PageUtil;
import com.cy.pj.sys.pojo.SysLog;
import com.cy.pj.sys.service.SysLogService;
import com.cy.pj.sys.web.pojo.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/log/")
public class SysLogController {
    @Autowired
    private SysLogService sysLogService;

    @PostMapping
    public JsonResult saveLog(@RequestBody SysLog sysLog){
        sysLogService.saveLog(sysLog);
        return new JsonResult("save ok");
    }

    @GetMapping("{id}")
    public JsonResult selectById(@PathVariable Long id){
        return new JsonResult(sysLogService.selectById(id));
    }

    @GetMapping
    public JsonResult selectLogs(SysLog sysLog){
        return new JsonResult(PageUtil.startPage().doSelectPageInfo(()->sysLogService.selectLogs(sysLog)));
    }

    @DeleteMapping("{id}")
    public JsonResult deleteLogs(@PathVariable Long... id){
        sysLogService.deleteLogs(id);
        return new JsonResult("delete ok");

    }
}
